/**
 * 添加或者修改页面
 */
var ToolInstallInfoDlg = {
    data: {
        goodsMode: "",
        gNum: "",
        gNum2: "",
        orderMode: "",
        oNum: "",
        oNum2: "",
        price: "",
        v1: "",
        v2: "",
        deptId: "",
        deliverId: ""
    }
};

layui.use(['form', 'admin', 'ax'], function () {
    var $ = layui.jquery;
    var $ax = layui.ax;
    var form = layui.form;
    var admin = layui.admin;

    //让当前iframe弹层高度适应
    admin.iframeAuto();

    //表单提交事件
    form.on('submit(btnSubmit)', function (data) {
        var ajax = new $ax(Feng.ctxPath + "/toolInstall/addItem", function (data) {
            Feng.success("添加成功！");
            window.location.href = Feng.ctxPath + '/toolInstall'
        }, function (data) {
            Feng.error("添加失败！" + data.responseJSON.message)
        });
        ajax.set(data.field);
        ajax.start();

        return false;
    });

    $("#v1_d").hide()
    $("#v2_d").hide()
    form.on('select(goodsMode)', function(data){
        var value = data.elem.value;//被点击的radio的value值
        if(value == "区间"){
            $("#gNum_d").show()
	    	$("#v1_d").hide()
        } else {
            $("#gNum_d").hide()
	    	$("#v1_d").show()
		}
    });
    form.on('select(orderMode)', function(data){
        var value = data.elem.value;//被点击的radio的value值
        if(value == "区间"){
            $("#oNum_d").show()
	    	$("#v2_d").hide()
        } else {
            $("#oNum_d").hide()
	    	$("#v2_d").show()
		}
    });

    //返回按钮
    $("#backupPage").click(function () {
        window.location.href = Feng.ctxPath + '/toolInstall'
    });

});